let express = require('express');
let router = express.Router();

const statService = require('../service/statService');
const checkJWTMiddleWare = require('../middleWare/checkJWTMiddleWare');

// 此路由需要登录后才能访问
router.use(checkJWTMiddleWare);

/*
 * 首页统计接口: 预警记录、测评记录、用户记录（学生）、咨询记录
 */
router.post('/statInfo', async function (req, res, next) {
    let statInfo = await statService.getStatInfo();
    res.json(statInfo);
});

/*
 * 首页统计接口: 显示近6个月的统计数据, 包含: 咨询记录统计、测评记录统计
 */
router.get('/curveInfo', async function (req, res, next) {
    // res.json({
    //     consult: [10, 44, 32, 21, 27, 35],
    //     test: [10, 44, 32, 21, 27, 35]
    // });
    let statInfo = await statService.curveInfo();
    res.json(statInfo);
});

module.exports = router;
